import redis

rc = redis.StrictRedis('127.0.0.1',db=0,port=6379)
#获取订阅对象
ps = rc.pubsub()
#订阅test信道信息
ps.subscribe('test')
#监听该信道的消息
#e.g.
# {'type': 'message', 'pattern': None, 'channel': b'test', 'data': b'hello world'}
for item in ps.listen():
    print(item)